package com.sky.controller.user;

import com.sky.constant.CommonConstant;
import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import com.sky.result.Result;
import com.sky.service.ShopCartService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("shopCartController")
@RequestMapping("/user/shoppingCart")
@Api(tags = "C端-购物车接口")
public class ShopCarController {
    @Autowired
    private ShopCartService shopCartService;

    @GetMapping("/list")
    public Result<List<ShoppingCart>> list(){
        List<ShoppingCart> list = shopCartService.list();
        return Result.success(list);
    }
    @PostMapping("/add")
    public Result add(@RequestBody ShoppingCartDTO shoppingCartDTO){
        shopCartService.add(shoppingCartDTO);
        return Result.success();
    }
    @PostMapping("/sub")
    public Result sub(@RequestBody ShoppingCartDTO shoppingCartDTO){
        shopCartService.sub(shoppingCartDTO);
        return Result.success();
    }
    @DeleteMapping("/clean")
    public Result clean(){
        shopCartService.clean();
        return Result.success();
    }

}
